<?php
error_reporting(E_ALL ^ E_NOTICE); 
ini_set('display_errors', '0');

/**
*  获取饿了么token
*/
class GetElemeToken
{
	
	/*
		获取饿了么token
		   app_key
		   app_secret
		   isSandboxEnvironment 判断是否沙箱环境
	*/
	public function getToken($app_key = '', $app_secret = '', $isSandboxEnvironment = true)
	{
		//实例化一个配置类
		$config = new Config($app_key, $app_secret, $isSandboxEnvironment);
		//使用config对象，实例化一个授权类
		$client = new OAuthClient($config);
		//使用授权类获取token
		$res = $client->get_token_in_client_credentials();
		$res = json_encode($res);
		$res = json_decode($res, true);

		return $res['access_token'];
	}
}

